%  This file is part of Erlywog.

%  Erlywog is free software: you can redistribute it and/or modify
%  it under the terms of the GNU General Public License as published by
%  the Free Software Foundation, either version 3 of the License, or
%  (at your option) any later version.

%  Erlywog is distributed in the hope that it will be useful,
%  but WITHOUT ANY WARRANTY; without even the implied warranty of
%  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%  GNU General Public License for more details.

%  You should have received a copy of the GNU General Public License
%  along with Erlywog.  If not, see <http://www.gnu.org/licenses/>.

%  Copyright Jasm Sison 2009
-module(blog_app_controller).
-export([hook/1]).

hook(Aorig) ->
	A =
	case yaws_arg:appmoddata(Aorig) of
		Root when (Root =:= "") orelse (Root =:= "/") ->
			yaws_arg:appmoddata(Aorig, "/blog/");
		_ -> Aorig
	end
	, {phased, {ewc, A},
		fun(_Ewc, Data, PhasedVars) ->
					CompleteData = [
						{data, erlyweb:get_app_root(A)}
						, {ewc, html_blog_header, [A, PhasedVars]}
						, {data, Data}
						%% comment out next three to display test mode
  						, {ewc, blog_navigator, [A, PhasedVars]} 
 						, {ewc, blog_sidebar, [A, PhasedVars]}
 						, {ewc, blog_footer, [A, PhasedVars]}
					]
					, {ewc, html_blog_container, [A, CompleteData]}
		end
	}.	
